<?php
/**
字符
 */
header('Content-type:text/html;charset=utf-8');

$s = "PHPsad\"fsa";
$s = 'PHPsad\'fsa';
$s = 'PHPsad"fsa';
echo $s;

//区别
echo "<br>*****<br>";
$a = "php";
$s = 'hello,$a';
echo $s;//变量会当作字符输出



echo "<br>*****<br>";
$a = "php";
$s = "hello,$a"; //在双引号中变量会被解析
echo $s;


//注意事项
echo "<br>*****<br>";
$a = 20;
$s = "my name is frank,I am $a ，years old"; //分隔的元则:变量后，无数字、下划线、字母（无变量合名规则）
echo $s;




//解决方法
echo "<br>*****<br>";
$a = 20;
$s = "my name is frank,I am {$a}years old"; //20year,例用花括号将变量包起来
echo $s;


//解决方法
echo "<br>*****<br>";
$a = 20;
$s = "my name is frank,I am ".$a."years old"; //20year,例用花括号将变量包起来
echo $s;



//单引号是否支持花括号
echo "<br>*****<br>";
$a = "php";
$s = 'hello,{$a}';
echo $s;//变量会当作字符输出


//区别：
//单引号定义的字符更快。
//如果有变量输出的需求，要么使用字符串拼接，要求省事一点可以使用双引号